package com.ytjj.qmyx.supplychain.api.controller;

import com.ytjj.qmyx.supplychain.common.api.CommonResult;
import com.ytjj.qmyx.supplychain.common.model.bill.request.BankerBillRequest;
import com.ytjj.qmyx.supplychain.common.model.bill.request.CreateBillRequest;
import com.ytjj.qmyx.supplychain.common.model.bill.request.EditBillRequest;
import com.ytjj.qmyx.supplychain.common.model.bill.request.BillPaymentRequest;
import com.ytjj.qmyx.supplychain.common.model.bill.request.BillSummaryRequest;
import com.ytjj.qmyx.supplychain.common.model.bill.request.*;
import com.ytjj.qmyx.supplychain.service.BillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *
 * 账单管理
 */
@Slf4j
@RestController
@RequestMapping("/bill")
public class BillController {

    @Resource
    private BillService billService;


    /**
     * 创建账单
     * @param request
     * @return
     */
    @PostMapping("/create")
    public CommonResult create(@RequestBody CreateBillRequest request){
        return billService.create(request);
    }

    /**
     * 编辑账单
     * @param request
     * @return
     */
    @PostMapping("/edit")
    public CommonResult edit(@RequestBody EditBillRequest request){
        return billService.edit(request);
    }

    /**
     * 该供应商的账单列表
     * @param request
     * @return
     */
    @PostMapping("/list")
    public CommonResult list(@RequestBody BankerBillRequest request){
        return billService.list(request);
    }
    /**
     * 对账完成
     * @param billId
     * @return
     */
    @GetMapping("/success")
    public CommonResult success(@RequestParam Integer billId){
        return billService.success(billId);
    }

    /**
     * 保存打款信息
     * @param request
     * @return
     */
    @PostMapping("/savePayment")
    public CommonResult savePayment(@RequestBody BillPaymentRequest request){
        return billService.savePayment(request);
    }

    /**
     * 系统对账
     * @param billId
     * @return
     */
    @GetMapping("/systemReconciliation")
    public CommonResult systemReconciliation(@RequestParam Integer billId){
        return billService.systemReconciliation(billId);
    }

    /**
     * 对账单详情
     * @param request
     * @return
     */
    @PostMapping("/getStatementDetails")
    public CommonResult getStatementDetails(@RequestBody BillOrderRequest request){
        return billService.getStatementDetails(request);
    }

    /**
     * 本期账单汇总
     */
    @PostMapping("/getBillSummary")
    public CommonResult getBillSummary(@RequestBody BillSummaryRequest request){
        return billService.getBillSummary(request);
    }

    /**
     * 对账单列表
     * @param request
     * @return
     */
    @PostMapping("/selectStatementList")
    public CommonResult selectStatementList(@RequestBody BillOrderRequest request){
        return CommonResult.success(billService.selectList(request));
    }

    /**
     * 账单下载
     */
    @PostMapping("/download")
    public CommonResult download(@RequestBody BillOrderRequest request){
        return billService.download(request);
    }

    /**
     * 获取供应商创建对账订单的参数
     * @param bankerId
     * @return
     */
    @GetMapping("/getBankerMsg")
    public CommonResult getBankerMsg(@RequestParam Integer bankerId){
        return billService.getBankerMsg(bankerId);
    }
}
